﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinUserAcc
{
    class LogManager
    {
        public static void WriteLog(string content)
        {
            var writer = new StreamWriter("c:\\南京中原批量添加域用户工具错误日志.txt", true, Encoding.Default);
            writer.WriteLine(content);
            writer.Flush();
            writer.Close();
        }

        public static void WriteException(Exception ex)
        {

            string strDateInfo = "出现异常:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n";

            var str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{2}\r\n", ex.GetType().Name,
                    ex.Message, ex.StackTrace);
            WriteLog(str);
        }
    }
}
